<template>
	<view class="body">
		<view class="addreserve" @click="$utils.navTo('/pages/recess/recessadd')"><p>+</p></view>
		<view class="header">
			<view class="uni-padding-wrap uni-common-mt">
				<uni-segmented-control :current="current" :values="items" style-type="text" active-color="#000" @clickItem="onClickItem" />
			</view>
			<view class="content">
				<view v-if="current === 0">
					<text class="content-text">
						<view class="record" v-for="item in list">
							<view class="top">
								<view class="photo"><image :src="url + item.studentPhoto" mode=""></image></view>
								<view class="message">
									<p class="title">3月17日 {{ item.studentName }}</p>
									<p class="kecheng">预约课程：{{ item.courseName }}</p>
									<p class="kecheng">课程老师：{{ item.teacherName }}</p>
									<p class="kecheng">请假时间：2022-7-16 10:30-11:00</p>
									<view class="remark">{{ item.remarks }}</view>
								</view>
							</view>
							<view class="bottom">
								<p>提交时间：{{ item.addtime }}</p>
								<view class="mess">{{ item.stateName }}</view>
							</view>
						</view>
						<view class="tishi" v-if="list.length == 0">
							<image src="../../assets/img/tishi.png" mode=""></image>
							<p>亲，您还没有已处理请假记录</p>
						</view>
					</text>
				</view>
				<view v-if="current === 1">
					<text class="content-text">
						<view class="record" v-for="item in list">
							<view class="top">
								<view class="photo"><image src="../../assets/img/tx.png" mode=""></image></view>
								<view class="message">
									<p class="title">3月17日 {{ item.studentName }}</p>
									<p class="kecheng">预约课程：{{ item.courseName }}</p>
									<p class="kecheng">课程老师：{{ item.teacherName }}</p>
									<p class="kecheng">请假时间：2022-7-16 10:30-11:00</p>
									<view class="remark">{{ item.remarks }}</view>
								</view>
							</view>
							<view class="bottom">
								<p>提交时间：{{ item.addtime }}</p>
								<view class="mess2">{{ item.stateName }}</view>
							</view>
						</view>
						<view class="tishi" v-if="list.length == 0">
							<image src="../../assets/img/tishi.png" mode=""></image>
							<p>亲，您还没有未处理的请假记录</p>
						</view>
					</text>
				</view>
				<view v-if="current === 2">
					<text class="content-text">
						<view class="record" v-for="item in list">
							<view class="top">
								<view class="photo"><image src="../../assets/img/tx.png" mode=""></image></view>
								<view class="message">
									<p class="title">3月17日 {{ item.studentName }}</p>
									<p class="kecheng">预约课程：{{ item.courseName }}</p>
									<p class="kecheng">课程老师：{{ item.teacherName }}</p>
									<p class="kecheng">请假时间：2022-7-16 10:30-11:00</p>
									<view class="remark">{{ item.remarks }}</view>
								</view>
							</view>
							<view class="bottom">
								<p>提交时间：{{ item.addtime }}</p>
								<view class="mess2">{{ item.stateName }}</view>
							</view>
						</view>
						<view class="tishi" v-if="list.length == 0">
							<image src="../../assets/img/tishi.png" mode=""></image>
							<p>亲，您还没有请假记录</p>
						</view>
					</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
import { IMGBASEURL } from '../../utils/config.js';
import { getleavelist } from '../../api/index.js';
export default {
	components: {},
	data() {
		return {
			url: IMGBASEURL,
			items: ['已处理的', '未处理的', '全部'],
			current: 0,
			list: [],
			params: {
				page: 1,
				psize: 4,
				statevalue: 1
			},
			total:0
		};
	},
	methods: {
		async getlist() {
			let res = await getleavelist(this.params);
			console.log(res)
			this.list = [...this.list,...res.data.list];
			this.total = res.data.pageCounts
		},
		onClickItem(e) {
			if (this.current !== e.currentIndex) {
				this.current = e.currentIndex;
				if (this.current == 0) {
					this.params.statevalue = 1;
					this.params.page=1
					this.list = [];
					this.getlist();
				} else if (this.current == 1) {
					this.params.page=1
					this.list = [];
					this.params.statevalue = 0;
					this.getlist();
				} else {
					this.params.statevalue = '';
					this.params.page=1
					this.list = [];
					this.getlist();
				}
			}
		}
	},
	onLoad() {
		this.getlist();
	},
	onPullDownRefresh() {
		this.params.page = 1;
		this.list = [];
		this.getlist();
		uni.stopPullDownRefresh();
	},
	onReachBottom() {
		this.params.page++;
		if (this.params.page <= this.total) {
			uni.hideNavigationBarLoading();
			uni.showToast({
				title: '暂无更多数据'
			});
			this.getlist();
		} else {
			this.getlist();
		}
	}
};
</script>

<style scoped lang="less">
@import './recess.less';
</style>
